package com.boyuan.system.common;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.boyuan.system.enums.ErrorCode;
import lombok.Data;

import java.io.Serializable;

/**
 * 通用返回类
 *
 * @param <T>
 * @author ply
 */
@Data
public class BaseResponse<T> implements Serializable {

    private int code;

    private T data;

    private String msg;

    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Integer count;


    public BaseResponse(int code, T data, String msg,int count) {
        this.code = code;
        this.data = data;
        this.msg = msg;
        this.count = count;
    }
    public BaseResponse(int code, T data, String msg) {
        this.code = code;
        this.data = data;
        this.msg = msg;
    }
    public BaseResponse(int code, T data) {
        this(code, data, "");
    }
    public BaseResponse(ErrorCode errorCode) {
        this(errorCode.getCode(), null, errorCode.getMessage());
    }



}
